package com.sams.controller;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.sams.entity.Authority;
 import com.sams.service.AuthorityService;
 import com.sams.util.SamResult;

@RequestMapping("/authority")
@Controller
public class AuthorityController {
	
	@Autowired
	private AuthorityService service;
 
 
	
	@RequestMapping("/add")
	public String add(Authority Authority,Model model) {
	 
		int count = service.add(Authority);
		return "forward:/authority/list";
	}
	
	
	
	
	@RequestMapping("/list")
	public String list(Integer currentPage,Model model) {
		if(currentPage==null || currentPage==0) {
			currentPage=1;
		}
		PageInfo<Authority> pageInfo = service.listByPage(currentPage);
		 model.addAttribute("pageInfo", pageInfo);
		 return "authority";
	}
	
	@RequestMapping("/delete")
	public String delele(Integer auid,Integer roleid) {
		int count = service.delete(auid,roleid);
		return "forward:/authority/list";
	}
 
	
	
}
